package ru.myrtle.umf.util;

import ru.myrtle.umf.UEnumeration;
import ru.myrtle.umf.UEnumerationLiteral;

public class UEnumerationConverter implements UConverter {

    private final UEnumeration uEnumeration;

    public UEnumerationConverter(UEnumeration uEnumeration) {
        this.uEnumeration = uEnumeration;
    }

    @Override
    public Object convertFromString(String source) {
        return uEnumeration.getLiteralByName(source);
    }

    @Override
    public String convertToString(Object source) {
        return ((UEnumerationLiteral) source).getName();
    }
}
